package com.patterns.demo.composite;

import java.util.Enumeration;
import java.util.Vector;

/**
 * Author: SamGroves
 * <p>
 * Description:
 * <p>
 * Date: 2017/12/3
 */
public class TreeNode {

    private String name;

    private TreeNode parent;

    public TreeNode(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public TreeNode getParent() {
        return parent;
    }

    public void setParent(TreeNode parent) {
        this.parent = parent;
    }

    private Vector<TreeNode> children = new Vector<>();

    // 添加子节点
    public void add(TreeNode node) {
        children.add(node);
    }

    // 删除子节点
    public void remove(TreeNode node) {
        children.remove(node);
    }

    //取得子节点
    public Enumeration<TreeNode> getChildren() {
        return children.elements();
    }
}
